#ifndef _USERMANANGER_H
#define _USERMANANGER_H
#include "User.hpp"
#include <map>
using std::map;

class UserMannger
{
public:

    static UserMannger * getUseMananger(){
        if(!u_mananger ){
            u_mananger = new UserMannger();
        }
        return u_mananger;
    }

    static void destory(){
        if(u_mananger ){
           delete u_mananger ;
           u_mananger = nullptr;
        }
    }

    void addUser(int fd ,User user);
    void delUser(int fd);
    void modifyUser(User user);
    User* getUser(int fd);
    map<int,User> & getUsers(){
        return _users;
    }

private:
    UserMannger() {}
    ~UserMannger() {}
    UserMannger(const UserMannger & ) = delete;
    UserMannger& operator=(const UserMannger &) = delete;
    static UserMannger * u_mananger;
    map<int,User> _users;
};
#endif

